package com.cavy.platform.client;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.validation.FieldError;
import org.springframework.validation.ObjectError;


@Data
@NoArgsConstructor
public class ErrorItem {
    private String field;
    private String message;

    public ErrorItem(String message) {
        this.message = message;
    }

    public ErrorItem(ObjectError error) {
        if (error instanceof FieldError) {
            this.field = ((FieldError) error).getField();
        }
        this.message = error.getDefaultMessage();
    }
}
